<?php

/**
 * @author Rizky Tahara Shita
 * @website http://tahara.web.id
 * @email rizky.tahara@gmail.com
 * @copyright b'IT Cyber Solution
 */

class M_polling_widget extends BZ_Model
{
	function __construct()
	{
		parent::__construct();
	}


/**
 * @section BISKITZ_FRONT Polling Widget Model
 * @description the model for biskitz polling
 */


	/**
	 * @function content_generate
	 * @description generate the content based on the category specified
	 */
	public function content_generate($prm_dbase = 'db_default')
	{
		$return_value = array
			(
				'QUESTION' => array
					(
						'ID' => ''
						, 'QUESTION' => ''
					)

				, 'CHOICES' => ''
			);

		/**
		 * @description get the polling question
		 */
		$question = $this->M_database->datas
			(
				$prm_dbase
				, 'biskitz_front_module_polling_questions'
				, array
					(
						'language__id' => $this->web_data['BISKITZ_FRONT']['LANGUAGE'][0]['id']
						, 'status' => 'Active'
					)
				, 'id, question'
				, FALSE
				, ''
				, ''
				, '', ''
				, FALSE
				, FALSE
			);

		if (is_array($question))
		{
			$return_value['QUESTION'] = array
				(
					'ID' => $question[0]['id']
					, 'QUESTION' => $question[0]['question']
				);

			/**
			 * @description get the polling choices
			 */
			$choices = $this->M_database->datas
				(
					$prm_dbase
					, 'biskitz_front_module_polling_questions_choices'
					, array
						(
							'questions__id' => $question[0]['id']
							, 'status' => 'Active'
						)
					, 'id, choice'
					, FALSE
					, 'orders'
					, ''
					, '', ''
					, FALSE
					, FALSE
				);

			if (is_array($choices))
			{
				foreach ($choices as $choices_rows)
				{
					/**
					 * @description generate the return value
					 */
					$return_value['CHOICES'][] = array
						(
							'id' => $choices_rows['id']
							, 'choice' => $choices_rows['choice']
						);
				}
			}
		}


		return $return_value;
	}



}

/** End of file m_polling_widget.php */
/** Location: ./biskitz_mpc/biskitz/models/biskitz/modules/polling/m_polling_widget.php */